#include <iostream>
#include "CreateData.h"
using namespace std;

void CreateData(int n) {
	//vector<int> data(n);
	int fd = open("data", O_WRONLY | O_TRUNC);

	srand(time(NULL));
	char data[20];
	for (int i = 0; i < n; ++i) {
		memset(data, 0, 20);
		if (i != n - 1)
			snprintf(data, 20, "%d ", rand() % (2 * n));
		else
			snprintf(data, 20, "%d", rand() % (2 * n));
		write(fd, data, strlen(data));
	}

	close(fd);
}

int main(int argc, char **argv) {
	if (argc != 2) {
		cerr<<"Usage: createdata [number],like createdata 40"<<endl;
		exit(1);
	}
	int n = atoi(argv[1]);
	CreateData(n);

	return 0;
}
